use redis::{RedisResult, Connection, Client};

use lazy_static::lazy_static;

lazy_static! {
    static ref REDIS_CLIENT: Client = init_client();
}

fn init_client() -> Client {
    Client::open("redis://:squbirreland@192.168.0.131:6379/2").unwrap()
}

pub fn conn() -> RedisResult<Connection> {
    REDIS_CLIENT.get_connection()
}

#[test]
fn test() {
    use redis::Commands;

    let mut connection = conn().unwrap();
    let result = redis::cmd("SET")
        .arg("belfast")
        .arg("squbirreland")
        .query::<String>(&mut connection);
    println!("{:?}", result);
    let result1 = connection.set::<_, _, String>("wow", "qs");
    println!("{:?}", result1);
    let result2 = connection.get::<_, String>("belfast");
    println!("{:?}", result2);
}